﻿Imports System.Data.OleDb
Public Class AddnewRestraurant
    Inherits System.Web.UI.Page



    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim myGUID As New System.Guid
        myGUID = Guid.NewGuid()

        Dim newFileName = myGUID.ToString() + ".jpg"

        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("RestraurantDataSource").ConnectionString)
        Dim SqlString As String = "Insert into londonrestraurants(restraurantName,Location,Stars,Description,ContactDetails,Picture,restrauranturl) Values (@f1,@f2,@f3,@f4,@f5,@f6,@f7)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", TextBox1.Text)
        cmd.Parameters.AddWithValue("@f2", TextBox2.Text)
        cmd.Parameters.AddWithValue("@f3", TextBox3)
        cmd.Parameters.AddWithValue("@f4", TextBox4.Text)
        cmd.Parameters.AddWithValue("@f5", TextBox5.Text)
        cmd.Parameters.AddWithValue("@f6", "images/" & newFileName)
        cmd.Parameters.AddWithValue("@f7", TextBox7.Text)
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        MsgBox("Added a new Restraurant")
        Response.Redirect("Default.aspx")
    End Sub
End Class